package co.edu.javeriana.touresbalon.oms.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author ada
 */
@Entity
@Table(name = "ITEMS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Items.findAll", query = "SELECT i FROM Items i"),
    @NamedQuery(name = "Items.findByItemid", query = "SELECT i FROM Items i WHERE i.itemsPK.itemid = :itemid"),
    @NamedQuery(name = "Items.findByProductid", query = "SELECT i FROM Items i WHERE i.productid = :productid"),
    @NamedQuery(name = "Items.findByProductname", query = "SELECT i FROM Items i WHERE i.productname = :productname"),
    @NamedQuery(name = "Items.findByPartnum", query = "SELECT i FROM Items i WHERE i.partnum = :partnum"),
    @NamedQuery(name = "Items.findByPrice", query = "SELECT i FROM Items i WHERE i.price = :price"),
    @NamedQuery(name = "Items.findByQuantity", query = "SELECT i FROM Items i WHERE i.quantity = :quantity"),
    @NamedQuery(name = "Items.findByOrderid", query = "SELECT i FROM Items i WHERE i.itemsPK.orderid = :orderid")})
public class Items implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ItemsPK itemsPK;
    @Column(name = "PRODUCTID")
    private BigInteger productid;
    @Size(max = 50)
    @Column(name = "PRODUCTNAME")
    private String productname;
    @Size(max = 20)
    @Column(name = "PARTNUM")
    private String partnum;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "PRICE")
    private BigDecimal price;
    @Column(name = "QUANTITY")
    private Integer quantity;
    @JoinColumn(name = "ORDERID", referencedColumnName = "ORDERID", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Orders orders;

    public Items() {
    }

    public Items(ItemsPK itemsPK) {
        this.itemsPK = itemsPK;
    }

    public Items(String itemid, String orderid) {
        this.itemsPK = new ItemsPK(itemid, orderid);
    }

    public ItemsPK getItemsPK() {
        return itemsPK;
    }

    public void setItemsPK(ItemsPK itemsPK) {
        this.itemsPK = itemsPK;
    }

    public BigInteger getProductid() {
        return productid;
    }

    public void setProductid(BigInteger productid) {
        this.productid = productid;
    }

    public String getProductname() {
        return productname;
    }

    public void setProductname(String productname) {
        this.productname = productname;
    }

    public String getPartnum() {
        return partnum;
    }

    public void setPartnum(String partnum) {
        this.partnum = partnum;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public Orders getOrders() {
        return orders;
    }

    public void setOrders(Orders orders) {
        this.orders = orders;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (itemsPK != null ? itemsPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof Items)) {
            return false;
        }
        Items other = (Items) object;
        if ((this.itemsPK == null && other.itemsPK != null) || (this.itemsPK != null && !this.itemsPK.equals(other.itemsPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "co.edu.javeriana.touresbalon.oms.entities.Items[ itemsPK=" + itemsPK + " ]";
    }
    
}
